//
//  WLHttpRequestAfter.m
//  YidianCan_Business
//
//  Created by scjh on 14/12/11.
//  Copyright (c) 2014年 John. All rights reserved.
//

#import "WLHttpRequestAfter.h"
#import "AFNetworking.h"
#import "DMCAlertCenter.h"
#import "SVProgressHUD.h"
#import "userInfoTool.h"


@implementation WLHttpRequestAfter


#pragma mark BaseRequest
///获取Dictionary数据
+ (void)getDictionaryWithStringURL:(NSString *)stringURL
                 usingSuccessBlock:(void (^)(NSDictionary *resultDictionary))successBlock
                   andFailureBlock:(void (^)(NSError *resultError))failureBlock
{
    
    [SVProgressHUD show];
    NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:stringURL]];
    AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
    __weak AFHTTPRequestOperation *weakOperation = operation;
    [operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
        successBlock([NSJSONSerialization JSONObjectWithData:weakOperation.responseData options:NSJSONReadingMutableContainers error:nil]);
        [SVProgressHUD dismiss];
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        failureBlock(error);
        [SVProgressHUD dismiss];
    }];
    [operation start];
}


//POST请求获取字典数据
+ (void)POSTDictionaryWithStringURL:(NSString *)stringURL
                              Parma:(NSDictionary *)parma
                       SuccessBlock:(void(^)(NSDictionary * resultDictionary))SuccessBlock
                       FailureBlock:(void(^)(NSError * error))FailureBlock{
    [SVProgressHUD show];

    
    
    AFHTTPRequestOperationManager * manger = [AFHTTPRequestOperationManager manager];
    [manger POST:stringURL
      parameters:parma
         success:^(AFHTTPRequestOperation *operation, id responseObject) {
        
           
             SuccessBlock(responseObject);
             [SVProgressHUD dismiss];
         } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
             FailureBlock(error);
             [SVProgressHUD dismiss];
         }];
}

/**注册-验证手机是否可以注册*/
+ (void)userCheckUserWithParam:(NSDictionary *)param
              usingSucessBlock:(void(^)(BOOL isSucess,NSDictionary * resultDictionary))sucessBlock
               andFailureBlock:(void (^)(NSError *resultError))failureBlock {
    
    NSString * urlString = [NSString stringWithFormat:@"%@/user/check_user",kMainUrl];
    [self POSTDictionaryWithStringURL:urlString Parma:param SuccessBlock:^(NSDictionary *resultDictionary) {
        
        sucessBlock(YES,resultDictionary);
    } FailureBlock:^(NSError *error) {
        
        failureBlock(error);
    }];
}

/**注册-手机发送验证码接口*/
+ (void)userSendRangCodeWithParam:(NSDictionary *)param
                 usingSucessBlock:(void(^)(BOOL isSucess,NSDictionary * resultDictionary))sucessBlock
                  andFailureBlock:(void (^)(NSError *resultError))failureBlock {
    
    NSString * urlString = [NSString stringWithFormat:@"%@/user/send_rangCode",kMainUrl];
    [self POSTDictionaryWithStringURL:urlString Parma:param SuccessBlock:^(NSDictionary *resultDictionary) {
        
        sucessBlock(YES,resultDictionary);
    } FailureBlock:^(NSError *error) {
        
        failureBlock(error);
    }];
}


/**注册-用户完善密码和昵称*/
+ (void)userRegisterWithParam:(NSDictionary *)param
             usingSucessBlock:(void(^)(BOOL isSucess,NSDictionary * resultDictionary))sucessBlock
              andFailureBlock:(void (^)(NSError *resultError))failureBlock {
    
    NSString * urlString = [NSString stringWithFormat:@"%@/user/user_register",kMainUrl];
    [self POSTDictionaryWithStringURL:urlString Parma:param SuccessBlock:^(NSDictionary *resultDictionary) {
        
        sucessBlock(YES,resultDictionary);
    } FailureBlock:^(NSError *error) {
        
        failureBlock(error);
    }];
}

/**用户登录*/
+ (void)userLoginWithParam:(NSDictionary *)param
          usingSucessBlock:(void(^)(BOOL isSucess,NSDictionary * resultDictionary))sucessBlock
           andFailureBlock:(void (^)(NSError *resultError))failureBlock {
    
    NSString * urlString = [NSString stringWithFormat:@"%@/user/user_login",kMainUrl];
    [self POSTDictionaryWithStringURL:urlString Parma:param SuccessBlock:^(NSDictionary *resultDictionary) {
        
        sucessBlock(YES,resultDictionary);
    } FailureBlock:^(NSError *error) {
        
        failureBlock(error);
    }];
}

/**用户个人中心-基本信息*/
+ (void)userCenterInfoWithParam:(NSDictionary *)param
               usingSucessBlock:(void(^)(BOOL isSucess,NSDictionary * resultDictionary))sucessBlock
                andFailureBlock:(void (^)(NSError *resultError))failureBlock {
    
    NSString * urlString = [NSString stringWithFormat:@"%@/user/userCenterInfo",kMainUrl];
    [self POSTDictionaryWithStringURL:urlString Parma:param SuccessBlock:^(NSDictionary *resultDictionary) {
        
        sucessBlock(YES,resultDictionary);
    } FailureBlock:^(NSError *error) {
        
        failureBlock(error);
    }];
}

/**个人中心-新增编辑地址*/
+ (void)userEditAddressWithParam:(NSDictionary *)param
                usingSucessBlock:(void(^)(BOOL isSucess,NSDictionary * resultDictionary))sucessBlock
                 andFailureBlock:(void (^)(NSError *resultError))failureBlock {
    NSString * urlString = [NSString stringWithFormat:@"%@/user/editAddress",kMainUrl];
    [self POSTDictionaryWithStringURL:urlString Parma:param SuccessBlock:^(NSDictionary *resultDictionary) {
        
        sucessBlock(YES,resultDictionary);
    } FailureBlock:^(NSError *error) {
        
        failureBlock(error);
    }];
}

/**个人中心-我的地址*/
+ (void)userGetUserAddressWithParam:(NSDictionary *)param
                   usingSucessBlock:(void(^)(BOOL isSucess,NSDictionary * resultDictionary))sucessBlock
                    andFailureBlock:(void (^)(NSError *resultError))failureBlock {
    
    NSString * urlString = [NSString stringWithFormat:@"%@/user/getUserAddress",kMainUrl];
    [self POSTDictionaryWithStringURL:urlString Parma:param SuccessBlock:^(NSDictionary *resultDictionary) {
        
        sucessBlock(YES,resultDictionary);
    } FailureBlock:^(NSError *error) {
        
        failureBlock(error);
    }];
}

/**个人中心-编辑个人信息*/
+ (void)userEditUserInfoWithParam:(NSDictionary *)param
                 usingSucessBlock:(void(^)(BOOL isSucess,NSDictionary * resultDictionary))sucessBlock
                  andFailureBlock:(void (^)(NSError *resultError))failureBlock {
    
    NSString * urlString = [NSString stringWithFormat:@"%@/user/editUserInfo",kMainUrl];
    [self POSTDictionaryWithStringURL:urlString Parma:param SuccessBlock:^(NSDictionary *resultDictionary) {
        
        sucessBlock(YES,resultDictionary);
    } FailureBlock:^(NSError *error) {
        
        failureBlock(error);
    }];
}
/**个人中心-我的分享*/
+ (void)userGetMyShareWithParam:(NSDictionary *)param
               usingSucessBlock:(void(^)(BOOL isSucess,NSDictionary * resultDictionary))sucessBlock
                andFailureBlock:(void (^)(NSError *resultError))failureBlock {
    
    NSString * urlString = [NSString stringWithFormat:@"%@/user/getMyShare",kMainUrl];
    [self POSTDictionaryWithStringURL:urlString Parma:param SuccessBlock:^(NSDictionary *resultDictionary) {
        
        sucessBlock(YES,resultDictionary);
    } FailureBlock:^(NSError *error) {
        
        failureBlock(error);
    }];
}

/**个人中心-私信*/
+ (void)userGetMyLetterWithParam:(NSDictionary *)param
                usingSucessBlock:(void(^)(BOOL isSucess,NSDictionary * resultDictionary))sucessBlock
                 andFailureBlock:(void (^)(NSError *resultError))failureBlock {
    
    NSString * urlString = [NSString stringWithFormat:@"%@/user/getMyLetter",kMainUrl];
    [self POSTDictionaryWithStringURL:urlString Parma:param SuccessBlock:^(NSDictionary *resultDictionary) {
        
        sucessBlock(YES,resultDictionary);
    } FailureBlock:^(NSError *error) {
        
        failureBlock(error);
    }];
}

/**个人中心-获取某人的私信*/
+ (void)userGetLetterForWithParam:(NSDictionary *)param
                 usingSucessBlock:(void(^)(BOOL isSucess,NSDictionary * resultDictionary))sucessBlock
                  andFailureBlock:(void (^)(NSError *resultError))failureBlock {
    
    NSString * urlString = [NSString stringWithFormat:@"%@/user/getLetterFor",kMainUrl];
    [self POSTDictionaryWithStringURL:urlString Parma:param SuccessBlock:^(NSDictionary *resultDictionary) {
        
        sucessBlock(YES,resultDictionary);
    } FailureBlock:^(NSError *error) {
        
        failureBlock(error);
    }];
}

/**活动列表*/
+ (void)activityGetActivityWithParam:(NSDictionary *)param
                    usingSucessBlock:(void(^)(BOOL isSucess,NSDictionary * resultDictionary))sucessBlock
                     andFailureBlock:(void (^)(NSError *resultError))failureBlock {
    
    NSString * urlString = [NSString stringWithFormat:@"%@/activity/getActivity",kMainUrl];
    [self POSTDictionaryWithStringURL:urlString Parma:param SuccessBlock:^(NSDictionary *resultDictionary) {
        
        sucessBlock(YES,resultDictionary);
    } FailureBlock:^(NSError *error) {
        
        failureBlock(error);
    }];
}

/**图片上传*/
+ (void)userUploadImageWithParam:(NSDictionary *)param
                usingSucessBlock:(void(^)(BOOL isSucess,NSDictionary * resultDictionary))sucessBlock
                 andFailureBlock:(void (^)(NSError *resultError))failureBlock {
    
    NSString * urlString = [NSString stringWithFormat:@"%@/user/upload_image",kMainUrl];
    NSData *data = UIImageJPEGRepresentation(param[@"filename"], 0.1);
    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
    [manager POST:urlString parameters:nil constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
        
        
        
        NSDate * today = [NSDate date];
        NSTimeZone *zone = [NSTimeZone systemTimeZone];
        NSInteger interval = [zone secondsFromGMTForDate:today];
        NSDate *localeDate = [today dateByAddingTimeInterval:interval];
        // 时间转换成时间戳
        NSString *timeSp = [NSString stringWithFormat:@"%ld",(long)[localeDate timeIntervalSince1970]];
        
        NSString *name = [NSString stringWithFormat:@"%@.jpg",timeSp];
        [formData appendPartWithFileData:data
                                    name:@"filename"
                                fileName:name
                                mimeType:@"image/jpg"];
        
        for (NSString *paramKey in param.allKeys) {
            
            if (![paramKey isEqualToString:@"filename"]) {
                
                [formData appendPartWithFormData:[param[paramKey] dataUsingEncoding:NSUTF8StringEncoding]
                                            name:paramKey];
            }
        }
        
    } success:^(AFHTTPRequestOperation *operation, id responseObject) {
        
        sucessBlock(YES,responseObject);
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        
        failureBlock(error);
    }];
   
}

/**个人中心-删除地址*/
+ (void)userdelAddressWithParam:(NSDictionary *)param
               usingSucessBlock:(void(^)(BOOL isSucess,NSDictionary * resultDictionary))sucessBlock
                andFailureBlock:(void (^)(NSError *resultError))failureBlock {
    
    NSString * urlString = [NSString stringWithFormat:@"%@/user/delAddress",kMainUrl];
    [self POSTDictionaryWithStringURL:urlString Parma:param SuccessBlock:^(NSDictionary *resultDictionary) {
        
        sucessBlock(YES,resultDictionary);
    } FailureBlock:^(NSError *error) {
        
        failureBlock(error);
    }];
}

/**获取动态列表*/
+ (void)userGetTrendWithParam:(NSDictionary *)param
             usingSucessBlock:(void(^)(BOOL isSucess,NSDictionary * resultDictionary))sucessBlock
              andFailureBlock:(void (^)(NSError *resultError))failureBlock {
    
    NSString * urlString = [NSString stringWithFormat:@"%@/user/getTrend",kMainUrl];
    [self POSTDictionaryWithStringURL:urlString Parma:param SuccessBlock:^(NSDictionary *resultDictionary) {
        
        sucessBlock(YES,resultDictionary);
    } FailureBlock:^(NSError *error) {
        
        failureBlock(error);
    }];
}

/**用户发布动态*/
+ (void)userPublishTrendWithParam:(NSDictionary *)param
                 usingSucessBlock:(void(^)(BOOL isSucess,NSDictionary * resultDictionary))sucessBlock
                  andFailureBlock:(void (^)(NSError *resultError))failureBlock {
    
    NSString * urlString = [NSString stringWithFormat:@"%@/user/publish_trend",kMainUrl];
    [self POSTDictionaryWithStringURL:urlString Parma:param SuccessBlock:^(NSDictionary *resultDictionary) {
        
        sucessBlock(YES,resultDictionary);
    } FailureBlock:^(NSError *error) {
        
        failureBlock(error);
    }];
}


/**用户回复动态*/
+ (void)userReplayTrendWithParam:(NSDictionary *)param
                usingSucessBlock:(void(^)(BOOL isSucess,NSDictionary * resultDictionary))sucessBlock
                 andFailureBlock:(void (^)(NSError *resultError))failureBlock {
    
    NSString * urlString = [NSString stringWithFormat:@"%@/user/replay_trend",kMainUrl];
    [self POSTDictionaryWithStringURL:urlString Parma:param SuccessBlock:^(NSDictionary *resultDictionary) {
        
        sucessBlock(YES,resultDictionary);
    } FailureBlock:^(NSError *error) {
        
        failureBlock(error);
    }];
}



/**个人中心-更新头像、相册*/
+ (void)userModifyHeadWithParam:(NSDictionary *)param
                usingSucessBlock:(void(^)(BOOL isSucess,NSDictionary * resultDictionary))sucessBlock
                 andFailureBlock:(void (^)(NSError *resultError))failureBlock {
    
    NSString * urlString = [NSString stringWithFormat:@"%@/user/modify_head",kMainUrl];
    
    
    NSData *data = UIImageJPEGRepresentation(param[@"filename"], 0.1);
    
    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
    [manager POST:urlString parameters:nil constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
        
        
       
        NSDate * today = [NSDate date];
        NSTimeZone *zone = [NSTimeZone systemTimeZone];
        NSInteger interval = [zone secondsFromGMTForDate:today];
        NSDate *localeDate = [today dateByAddingTimeInterval:interval];
        // 时间转换成时间戳
        NSString *timeSp = [NSString stringWithFormat:@"%ld",(long)[localeDate timeIntervalSince1970]];
        
        NSString *name = [NSString stringWithFormat:@"%@.jpg",timeSp];
        [formData appendPartWithFileData:data
                                    name:@"filename"
                                fileName:name
                                mimeType:@"image/jpg"];
        
        for (NSString *paramKey in param.allKeys) {
            
            if (![paramKey isEqualToString:@"filename"]) {
                
                [formData appendPartWithFormData:[param[paramKey] dataUsingEncoding:NSUTF8StringEncoding]
                                            name:paramKey];
            }
        }

    } success:^(AFHTTPRequestOperation *operation, id responseObject) {
    
        sucessBlock(YES,responseObject);
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
       
        failureBlock(error);
    }];
    
}

/**删除图片*/
+ (void)userDelPhotoWithParam:(NSDictionary *)param
             usingSucessBlock:(void(^)(BOOL isSucess,NSDictionary * resultDictionary))sucessBlock
              andFailureBlock:(void (^)(NSError *resultError))failureBlock {
    
    NSString * urlString = [NSString stringWithFormat:@"%@/user/del_photo",kMainUrl];
    [self POSTDictionaryWithStringURL:urlString Parma:param SuccessBlock:^(NSDictionary *resultDictionary) {
        
        sucessBlock(YES,resultDictionary);
    } FailureBlock:^(NSError *error) {
        
        failureBlock(error);
    }];
}

/**删除动态*/
+ (void)userDelTrendWithParam:(NSDictionary *)param
             usingSucessBlock:(void(^)(BOOL isSucess,NSDictionary * resultDictionary))sucessBlock
              andFailureBlock:(void (^)(NSError *resultError))failureBlock {
    
    NSString * urlString = [NSString stringWithFormat:@"%@/user/del_trend",kMainUrl];
    [self POSTDictionaryWithStringURL:urlString Parma:param SuccessBlock:^(NSDictionary *resultDictionary) {
        
        sucessBlock(YES,resultDictionary);
    } FailureBlock:^(NSError *error) {
        
        failureBlock(error);
    }];
}


/**获取动态评论列表*/
+ (void)userGetrendDiscussWithParam:(NSDictionary *)param
                   usingSucessBlock:(void(^)(BOOL isSucess,NSDictionary * resultDictionary))sucessBlock
                    andFailureBlock:(void (^)(NSError *resultError))failureBlock {
    
    NSString * urlString = [NSString stringWithFormat:@"%@/user/getTrendsDiscuss",kMainUrl];
    [self POSTDictionaryWithStringURL:urlString Parma:param SuccessBlock:^(NSDictionary *resultDictionary) {
        
        sucessBlock(YES,resultDictionary);
    } FailureBlock:^(NSError *error) {
        
        failureBlock(error);
    }];
    
}

/**获取省市区列表*/
+ (void)addressListWithParam:(NSDictionary *)param
            usingSucessBlock:(void(^)(BOOL isSucess,NSDictionary * resultDictionary))sucessBlock
             andFailureBlock:(void (^)(NSError *resultError))failureBlock {
    
    NSString * urlString = [NSString stringWithFormat:@"%@/area/getArea",kMainUrl];
    [self POSTDictionaryWithStringURL:urlString Parma:param SuccessBlock:^(NSDictionary *resultDictionary) {
        
        sucessBlock(YES,resultDictionary);
    } FailureBlock:^(NSError *error) {
        
        failureBlock(error);
    }];
}

/**获取话题接口*/
+ (void)userGetTopicWithParam:(NSDictionary *)param
             usingSucessBlock:(void(^)(BOOL isSucess,NSDictionary * resultDictionary))sucessBlock
              andFailureBlock:(void (^)(NSError *resultError))failureBlock {
    
    NSString * urlString = [NSString stringWithFormat:@"%@/user/getTopic",kMainUrl];
    [self POSTDictionaryWithStringURL:urlString Parma:param SuccessBlock:^(NSDictionary *resultDictionary) {
        
        sucessBlock(YES,resultDictionary);
    } FailureBlock:^(NSError *error) {
        
        failureBlock(error);
    }];
}

/**查询列表接口*/
+ (void)bannerGetBannerWithParam:(NSDictionary *)param
                usingSucessBlock:(void(^)(BOOL isSucess,NSDictionary * resultDictionary))sucessBlock
                 andFailureBlock:(void (^)(NSError *resultError))failureBlock {
    
    NSString * urlString = [NSString stringWithFormat:@"%@/banner/getBanner",kMainUrl];
    [self POSTDictionaryWithStringURL:urlString Parma:param SuccessBlock:^(NSDictionary *resultDictionary) {
        
        sucessBlock(YES,resultDictionary);
    } FailureBlock:^(NSError *error) {
        
        failureBlock(error);
    }];
}

/**收到的评论和发的评论*/
+ (void)userGetCenterDiscussWithParam:(NSDictionary *)param
                     usingSucessBlock:(void(^)(BOOL isSucess,NSDictionary * resultDictionary))sucessBlock
                      andFailureBlock:(void (^)(NSError *resultError))failureBlock {
    NSString * urlString = [NSString stringWithFormat:@"%@/user/getCenter_discuss",kMainUrl];
    [self POSTDictionaryWithStringURL:urlString Parma:param SuccessBlock:^(NSDictionary *resultDictionary) {
        
        sucessBlock(YES,resultDictionary);
    } FailureBlock:^(NSError *error) {
        
        failureBlock(error);
    }];
}

/**个人中心-我的钱包*/
+ (void)userGetMyWalletWithParam:(NSDictionary *)param
                usingSucessBlock:(void(^)(BOOL isSucess,NSDictionary * resultDictionary))sucessBlock
                 andFailureBlock:(void (^)(NSError *resultError))failureBlock {
    
    NSString * urlString = [NSString stringWithFormat:@"%@/user/getMyWallet",kMainUrl];
    [self POSTDictionaryWithStringURL:urlString Parma:param SuccessBlock:^(NSDictionary *resultDictionary) {
        
        sucessBlock(YES,resultDictionary);
    } FailureBlock:^(NSError *error) {
        
        failureBlock(error);
    }];
}

/**个人中心-支付宝绑定*/
+ (void)userBindAlipayWithParam:(NSDictionary *)param
               usingSucessBlock:(void(^)(BOOL isSucess,NSDictionary * resultDictionary))sucessBlock
                andFailureBlock:(void (^)(NSError *resultError))failureBlock {
 
    NSString * urlString = [NSString stringWithFormat:@"%@/user/bindAlipay",kMainUrl];
    [self POSTDictionaryWithStringURL:urlString Parma:param SuccessBlock:^(NSDictionary *resultDictionary) {
        
        sucessBlock(YES,resultDictionary);
    } FailureBlock:^(NSError *error) {
        
        failureBlock(error);
    }];
}


/**个人中心-提现获取已绑定的支付宝*/
+ (void)userGetAlipayWithParam:(NSDictionary *)param
              usingSucessBlock:(void(^)(BOOL isSucess,NSDictionary * resultDictionary))sucessBlock
               andFailureBlock:(void (^)(NSError *resultError))failureBlock {
    
    NSString * urlString = [NSString stringWithFormat:@"%@/user/getAlipay",kMainUrl];
    [self POSTDictionaryWithStringURL:urlString Parma:param SuccessBlock:^(NSDictionary *resultDictionary) {
        
        sucessBlock(YES,resultDictionary);
    } FailureBlock:^(NSError *error) {
        
        failureBlock(error);
    }];
}

/**个人中心-分享回调*/
+ (void)usercallBackShareWithParam:(NSDictionary *)param
                  usingSucessBlock:(void(^)(BOOL isSucess,NSDictionary * resultDictionary))sucessBlock
                   andFailureBlock:(void (^)(NSError *resultError))failureBlock {
    
    NSString * urlString = [NSString stringWithFormat:@"%@/user/callback_share",kMainUrl];
    [self POSTDictionaryWithStringURL:urlString Parma:param SuccessBlock:^(NSDictionary *resultDictionary) {
        
        sucessBlock(YES,resultDictionary);
    } FailureBlock:^(NSError *error) {
        
        failureBlock(error);
    }];
}



/**个个人中心-申请提现*/
+ (void)userApplyForWithParam:(NSDictionary *)param
             usingSucessBlock:(void(^)(BOOL isSucess,NSDictionary * resultDictionary))sucessBlock
              andFailureBlock:(void (^)(NSError *resultError))failureBlock {
    
    NSString * urlString = [NSString stringWithFormat:@"%@/user/applyFor",kMainUrl];
    [self POSTDictionaryWithStringURL:urlString Parma:param SuccessBlock:^(NSDictionary *resultDictionary) {
        
        sucessBlock(YES,resultDictionary);
    } FailureBlock:^(NSError *error) {
        
        failureBlock(error);
    }];
}



/**个人中心-回复私信*/
+ (void)userReplyLetterWithParam:(NSDictionary *)param
                usingSucessBlock:(void(^)(BOOL isSucess,NSDictionary * resultDictionary))sucessBlock
                 andFailureBlock:(void (^)(NSError *resultError))failureBlock {
    
    NSString * urlString = [NSString stringWithFormat:@"%@/user/replyLetter",kMainUrl];
    [self POSTDictionaryWithStringURL:urlString Parma:param SuccessBlock:^(NSDictionary *resultDictionary) {
        
        sucessBlock(YES,resultDictionary);
    } FailureBlock:^(NSError *error) {
        
        failureBlock(error);
    }];
}

/**个人中心-删除私信*/
+ (void)userDeleteLetterWithParam:(NSDictionary *)param
                 usingSucessBlock:(void(^)(BOOL isSucess,NSDictionary * resultDictionary))sucessBlock
                  andFailureBlock:(void (^)(NSError *resultError))failureBlock {
    
    NSString * urlString = [NSString stringWithFormat:@"%@/user/deleteLetter",kMainUrl];
    [self POSTDictionaryWithStringURL:urlString Parma:param SuccessBlock:^(NSDictionary *resultDictionary) {
        
        sucessBlock(YES,resultDictionary);
    } FailureBlock:^(NSError *error) {
        
        failureBlock(error);
    }];
}

/**下订单*/
+ (void)userOrderWithParam:(NSDictionary *)param
          usingSucessBlock:(void(^)(BOOL isSucess,NSDictionary * resultDictionary))sucessBlock
           andFailureBlock:(void (^)(NSError *resultError))failureBlock {
    
    NSString * urlString = [NSString stringWithFormat:@"%@/user/order",kMainUrl];
    [self POSTDictionaryWithStringURL:urlString Parma:param SuccessBlock:^(NSDictionary *resultDictionary) {
        
        sucessBlock(YES,resultDictionary);
    } FailureBlock:^(NSError *error) {
        
        failureBlock(error);
    }];
}

/**获取订单*/
+ (void)userGetOrderWithParam:(NSDictionary *)param
             usingSucessBlock:(void(^)(BOOL isSucess,NSDictionary * resultDictionary))sucessBlock
              andFailureBlock:(void (^)(NSError *resultError))failureBlock {
    
    NSString * urlString = [NSString stringWithFormat:@"%@/user/getOrder",kMainUrl];
    [self POSTDictionaryWithStringURL:urlString Parma:param SuccessBlock:^(NSDictionary *resultDictionary) {
        
        sucessBlock(YES,resultDictionary);
    } FailureBlock:^(NSError *error) {
        
        failureBlock(error);
    }];
}


/**订单支付回调*/
+ (void)userOrderPayWithParam:(NSDictionary *)param
             usingSucessBlock:(void(^)(BOOL isSucess,NSDictionary * resultDictionary))sucessBlock
              andFailureBlock:(void (^)(NSError *resultError))failureBlock {
    
    NSString * urlString = [NSString stringWithFormat:@"%@/user/getOrder",kMainUrl];
    [self POSTDictionaryWithStringURL:urlString Parma:param SuccessBlock:^(NSDictionary *resultDictionary) {
        
        sucessBlock(YES,resultDictionary);
    } FailureBlock:^(NSError *error) {
        
        failureBlock(error);
    }];
}


/**找回密码-验证用户*/
+ (void)userFindPasswordWithParam:(NSDictionary *)param
                 usingSucessBlock:(void(^)(BOOL isSucess,NSDictionary * resultDictionary))sucessBlock
                  andFailureBlock:(void (^)(NSError *resultError))failureBlock {
   
    NSString * urlString = [NSString stringWithFormat:@"%@/user/find_password",kMainUrl];
    [self POSTDictionaryWithStringURL:urlString Parma:param SuccessBlock:^(NSDictionary *resultDictionary) {
        
        sucessBlock(YES,resultDictionary);
    } FailureBlock:^(NSError *error) {
        
        failureBlock(error);
    }];
}

/**找回密码-验证用户*/
+ (void)userModifyPasswordWithParam:(NSDictionary *)param
                   usingSucessBlock:(void(^)(BOOL isSucess,NSDictionary * resultDictionary))sucessBlock
                    andFailureBlock:(void (^)(NSError *resultError))failureBlock {
    
    NSString * urlString = [NSString stringWithFormat:@"%@/user/modify_password",kMainUrl];
    [self POSTDictionaryWithStringURL:urlString Parma:param SuccessBlock:^(NSDictionary *resultDictionary) {
        
        sucessBlock(YES,resultDictionary);
    } FailureBlock:^(NSError *error) {
        
        failureBlock(error);
    }];
}

/**第三方账号登陆接口*/
+ (void)userLoginAuthoWithParam:(NSDictionary *)param
               usingSucessBlock:(void(^)(BOOL isSucess,NSDictionary * resultDictionary))sucessBlock
                andFailureBlock:(void (^)(NSError *resultError))failureBlock {
    
    NSString * urlString = [NSString stringWithFormat:@"%@/user/loginAutho",kMainUrl];
    [self POSTDictionaryWithStringURL:urlString Parma:param SuccessBlock:^(NSDictionary *resultDictionary) {
        
        sucessBlock(YES,resultDictionary);
    } FailureBlock:^(NSError *error) {
        
        failureBlock(error);
    }];
}

/**验证验证码是否正确*/
+ (void)userCheckCodeWithParam:(NSDictionary *)param
              usingSucessBlock:(void(^)(BOOL isSucess,NSDictionary * resultDictionary))sucessBlock
               andFailureBlock:(void (^)(NSError *resultError))failureBlock {
    
    NSString * urlString = [NSString stringWithFormat:@"%@/user/check_code",kMainUrl];
    [self POSTDictionaryWithStringURL:urlString Parma:param SuccessBlock:^(NSDictionary *resultDictionary) {
        
        sucessBlock(YES,resultDictionary);
    } FailureBlock:^(NSError *error) {
        
        failureBlock(error);
    }];
}

@end
